{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python算术运算符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "c =  30\n",
      "1 - c =  -29\n",
      "a / b =  0.5\n",
      "b / a =  2.0\n",
      "a % b =  10\n",
      "b % a =  0\n"
     ]
    }
   ],
   "source": [
    "# Python2.x 里，整数除整数，只能得出整数。如果要得到小数部分，把其中一个数改成浮点数即可。\n",
    "a = 10\n",
    "b = 20\n",
    "c = 0\n",
    "c = a + b\n",
    "print(\"c = \",c)\n",
    "print(\"1 - c = \",1 - c)\n",
    "print('a / b = ',a / b)\n",
    "print('b / a = ',b / a)\n",
    "print('a % b = ', a % b)\n",
    "print('b % a = ', b % a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python比较运算符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a == b  False\n",
      "a != b  True\n",
      "a > b  True\n",
      "b < a  True\n",
      "a >= b  True\n"
     ]
    }
   ],
   "source": [
    "a = 21\n",
    "b = 10\n",
    "\n",
    "print(\"a == b \",a == b)\n",
    "print(\"a != b \",a != b)\n",
    "print(\"a > b \",a > b)\n",
    "print(\"b < a \",b < a)\n",
    "print(\"a >= b \",a >= b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python赋值运算符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a + b 30\n",
      "b - a  10\n",
      "c += a  20\n",
      "c *= a  200\n",
      "c **= a  102400000000000000000000\n"
     ]
    }
   ],
   "source": [
    "a = 10\n",
    "b = 20\n",
    "c = a+b\n",
    "print('a + b',c)\n",
    "c = b - a\n",
    "print('b - a ',c)\n",
    "c += a\n",
    "print('c += a ',c)\n",
    "c *= a\n",
    "print('c *= a ',c)\n",
    "c **= a\n",
    "print('c **= a ',c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
